﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace BestTrader.Cms.Core.Extensions
{
    public static class HttpClientExtensions
    {
        public static Task<HttpResponseMessage> PostAsync(this IHttpClientFactory _clientFactory, string requestUri, string argments)
        {
            var client = _clientFactory.CreateClient(Constants.HTTP_RMMSOFT);

            var content = new StringContent(argments);
            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");

            return client.PostAsync(requestUri, content);
        }

        public static Task<HttpResponseMessage> GetAsync(this IHttpClientFactory _clientFactory, string requestUri)
        {
            var client = _clientFactory.CreateClient(Constants.HTTP_RMMSOFT);

            return client.GetAsync(requestUri);
        }
    }
}
